<template>
  <!-- 商城设置  店铺参数配置 -->
  <div class="shop-config-page">
    <div class="flex-box flex">
      <div class="left">
        <el-descriptions class="margin-top" :labelStyle="{width:'150px',fontWeight:'bold',color:'#333'}" title="基础配置" :column="1" size="big" border>
          <el-descriptions-item v-if="checkPermi(['shopParams:goodsCheck'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>启用：发布商品后会到商品审核目录，需要审核后才上架到未售商品中。</span><br />
                    <span>禁用：发布商品后无需审核立即上架到未售商品中。</span>
                    <span style="color:red">注意：无论该功能是否启用，批量发布的商品都需要审核。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.goodsAudit.configName }}</b>

            </div>
            <el-radio-group v-model="form.goodsAudit.configValue" @change="submit($event,'goodsAudit')">
              <el-radio label="1">启用</el-radio>
              <el-radio label="2">禁用</el-radio>
            </el-radio-group>
          </el-descriptions-item>
          <el-descriptions-item :label="form.gameList.configName" v-if="checkPermi(['shopParams:customGameList'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>启用：使用“设置管理>游戏管理”中配置的游戏，作为自营商城展示的游戏列表。启用前请确保配置了游戏！</span><br />
                    <span>禁用：使用系统内所有的游戏，作为自营商城展示的游戏列表。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.gameList.configName }}</b>
            </div>
            <el-radio-group v-model="form.gameList.configValue" @change="submit($event,'gameList')">
              <el-radio label="1">启用</el-radio>
              <el-radio label="2">禁用</el-radio>
            </el-radio-group>
          </el-descriptions-item>
          <el-descriptions-item :label="form.guaranteeConfig.configName" v-if="checkPermi(['shopParams:customGuaranteeConfig'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>包赔费：用户购买商品时选择找回包赔，需要额外支付的费用，按商品金额的百分比计算。</span><br />
                    <span>最低包赔费：用户购买商品时选择找回包赔，通过包赔费百分比计算的金额不足最低包赔费时，按照最低包赔分收取。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.guaranteeConfig.configName }}</b>
            </div>
            <div class="flex">
              <div>
                <el-button type="primary" style="margin-left:10px" @click="openBaopei($event,'guaranteeConfig')">修改包赔设置</el-button>
              </div>
            </div>
          </el-descriptions-item>

          <el-descriptions-item :label="form.unsoldDays.configName" v-if="checkPermi(['shopParams:unsoldDays'])">
            <div slot="label">

              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>首页统计滞销商品数量时以当前设置的天数为准，超过该天数未售的商品统计为滞销商品。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.unsoldDays.configName }}</b>
            </div>
            <el-input @change="submit($event,'unsoldDays')" type="number" style="width:100px" v-model="form.unsoldDays.configValue" placeholder="">
              <span style="line-height:36px" slot="suffix">天</span>
            </el-input>

          </el-descriptions-item>
          <!-- 分销开关 -->
          <el-descriptions-item :label="form.daishou.configName" v-if="checkPermi(['shopParams:daishou'])">
            <div slot="label">

              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>启用：其他商户可以在货源配置看到你的商品并选择代售。</span><br />
                    <span>禁用：其他商户可以在货源配置不可看到你的商品。</span>
                    <span style="color: red;">禁用前如果已有人代售你的商品，须主动联系代售人取消代售。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.daishou.configName }}</b>
            </div>
            <el-radio-group v-model="form.daishou.configValue" @change="submit($event,'daishou')">
              <el-radio label="1">启用</el-radio>
              <el-radio label="2">禁用</el-radio>
            </el-radio-group>
          </el-descriptions-item>

          <!-- 订单支付提醒 短信提醒 -->
          <el-descriptions-item :label="form.zhifutixing.configName" v-if="checkPermi(['shopParams:zhifutixing'])">
            <div slot="label">

              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>启用：用户付款后系统会发送一条短信提醒，不设置手机号时发送给店铺管理员的手机号。<br />
                      短信扣除系统短信条数。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.zhifutixing.configName }}</b>
            </div>
            <div>
              <el-radio-group v-model="zhifutixingConfigMap.state">
                <el-radio label="1">启用</el-radio>
                <el-radio label="2">禁用</el-radio>
              </el-radio-group>
              <div style="margin-top:10px">
                <b>手机号：</b>
                <el-input type="text" style="width: 250px;" v-model="zhifutixingConfigMap.phone" placeholder="接收短信提醒的手机号">
                </el-input>
              </div>
              <div style="margin-top: 10px">
                <el-button type="primary" style="margin-left:10px" @click="submit($event,'zhifutixing')">保存</el-button>
                <el-button type="danger" plain style="margin-left:10px" v-if="form.dingding.id" @click="delShopParamsFn($event,form.zhifutixing.id)">清空</el-button>
              </div>
            </div>

          </el-descriptions-item>
          <!-- 包赔端设置 -->
          <el-descriptions-item  v-if="checkPermi(['shopParams:guaranteeServiceAmount'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>包赔费：用户选择你做包赔商时，系统按照该设置自动计算包赔费。</span><br />
                    <span>手续费：用户选择你做包赔商时，系统按照该设置自动填充手续费。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.guaranteeServiceAmount.configName }}</b>
            </div>
            <div class="flex">
              <div>
                <el-button type="primary" style="margin-left:10px" @click="openGuaranteeServiceAmountDialog()">修改设置</el-button>
              </div>
            </div>
          </el-descriptions-item>
          <!-- 包赔端设置 -->
          <el-descriptions-item  v-if="checkPermi(['shopParams:zidongguazhang'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>在商家货源中，同行向你提号下单时，设置哪个商家可以自动挂账到交易中。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.zidongguazhang.configName }}</b>
            </div>
            <div class="flex">
              <div>
                <el-button type="primary" style="margin-left:10px" @click="openZidongguazhang()">修改设置</el-button>
              </div>
            </div>
          </el-descriptions-item>

          <!--报价提醒短信  -->
          <el-descriptions-item v-if="checkPermi(['shopParams:quotation'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>开启后，在"竞拍市场"报价时，系统将自动发送一条短信提醒卖家上线查看;消耗你的系统短信数量。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.quotation.configName }}</b>

            </div>
            <el-radio-group v-model="form.quotation.configValue" @change="submit($event,'quotation')">
              <el-radio label="1">启用</el-radio>
              <el-radio label="2">禁用</el-radio>
            </el-radio-group>
          </el-descriptions-item>
          <!-- 自动生成自编号 -->
          <el-descriptions-item v-if="checkPermi(['shopParams:autoZibianhao'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>开启后，在"商品发布"时，系统将自动生成自编号，但是生成的自编号有概率会重复。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.autoZibianhao.configName }}</b>

            </div>
            <el-radio-group v-model="form.autoZibianhao.configValue" @change="submit($event,'autoZibianhao')">
              <el-radio label="1">启用</el-radio>
              <el-radio label="2">禁用</el-radio>
            </el-radio-group>
          </el-descriptions-item>

        </el-descriptions>
        <el-descriptions class="margin-top" :labelStyle="{width:'150px',fontWeight:'bold',color:'#333'}" title="卡位短信相关" :column="1" size="big" border>
          <!-- 卡位短信设置 -->
          <el-descriptions-item :label="form.duanxinChaxun.configName" v-if="checkPermi(['shopParams:duanxinChaxun'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>卡位收短信相关的设置，包括隐藏短信内容，留存查看记录，短信提醒过滤等。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.duanxinChaxun.configName }}</b>
            </div>
            <div class="flex">
              <el-button type="primary" style="margin-left:10px" @click="openSmsSetting()">修改设置</el-button>
            </div>
          </el-descriptions-item>
          <!-- 自动通话 设置 -->
          <el-descriptions-item  v-if="checkPermi(['shopParams:autoCallDays'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>设置卡位号码自动通话周期，系统按照这个设置让号卡进行拨打电话，每次通话1分钟；目前仅支持“全网通双卡”类型设备。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.autoCallDays.configName }}</b>
            </div>
            <div>
                <!-- <el-input @change="submit($event,'autoCallDays')" type="number" style="width: 100px;" v-model="form.autoCallDays.configValue" placeholder="周期">
                  <span style="line-height:36px" slot="suffix">天</span>
                </el-input> -->
                <el-button type="primary" style="margin-left:10px" @click="openAutoCallSetting()">修改设置</el-button>
            </div>
          </el-descriptions-item>
          <!-- 短信屏蔽关键词 -->
          <el-descriptions-item  v-if="checkPermi(['shopParams:duanxinChaxun'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>设置拒收的短信关键词，多个词用逗号隔开，包含关键词的短信将不再接收。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.duanxinguolvci.configName }}</b>
            </div>
            <div>
              <div>
                <el-input @change="submit($event,'duanxinguolvci')" :rows="3" type="textarea" style="width:400px" v-model="form.duanxinguolvci.configValue" placeholder="拒收的短信关键词，多个词用逗号隔开">
                </el-input>
              </div>
            </div>
          </el-descriptions-item>
          
          <!-- 钉钉群机器人配置 -->
          <el-descriptions-item :label="form.dingding.configName" v-if="checkPermi(['shopParams:dingding'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>本功能用于将智能卡位收到的短信转发到钉钉群中。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.dingding.configName }}</b>
            </div>
            <div>
              <div>
                <b>Webhook地址：</b>
                <el-input type="textarea" style="width:400px" v-model="dingdingMap.webhook" placeholder="Webhook地址">
                </el-input>
              </div>
              <div style="margin-top:10px">
                <b>加签字符串：</b>
                <el-input type="textarea" style="width:400px" v-model="dingdingMap.secret" placeholder="加签字符串">
                </el-input>
              </div>
              <div style="margin-top: 10px">
                <el-button type="primary" style="margin-left:10px" @click="submit($event,'dingding')">保存</el-button>
                <el-button type="danger" plain style="margin-left:10px" v-if="form.dingding.id" @click="delShopParamsFn($event,form.dingding.id)">清空</el-button>
              </div>
            </div>
            <div style="margin-top:5px;color:#999">

              <span>
                在钉钉群添加机器人，选择加签方式生成参数，复制粘贴在本配置内保存即可。
              </span>
            </div>
          </el-descriptions-item>
          <!-- 企业微信机器人配置 -->
          <el-descriptions-item :label="form.qiyeweixin.configName" v-if="checkPermi(['shopParams:qiyeweixin'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>本功能用于将智能卡位收到的短信转发到企业微信群中。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.qiyeweixin.configName }}</b>
            </div>
            <div>
              <div>
                <b>Webhook地址：</b>
                <el-input type="textarea" style="width:400px" v-model="form.qiyeweixin.configValue" placeholder="Webhook地址">
                </el-input>
                <el-button type="primary" style="margin-left:10px" @click="submit($event,'qiyeweixin')">保存</el-button>
                <el-button type="danger" plain style="margin-left:10px" v-if="form.qiyeweixin.id" @click="delShopParamsFn($event,form.qiyeweixin.id)">清空</el-button>
              </div>
            </div>
            <div style="margin-top:5px;color:#999">
              <span>
                在企业微信群添加机器人，将生成的Webhook地址复制粘贴在本配置内保存即可。
              </span>
            </div>
          </el-descriptions-item>
          
        </el-descriptions>
        <el-descriptions class="margin-top" :labelStyle="{width:'150px',fontWeight:'bold',color:'#333'}" title="租号设置" :column="1" size="big" border>
            <el-descriptions-item :label="form.accountRental.configName" v-if="checkPermi(['shopParams:accountRental'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>租号服务费按照租金的百分比计算，如果低于最低金额按照最低金额计算，服务费由号主承担。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.accountRental.configName }}</b>
            </div>
          <div class="flex">
              <div>
                <el-button type="primary" style="margin-left:10px" @click="openAcccount($event,'guaranteeConfig')">租号服务费设置</el-button>
              </div>
            </div>

          </el-descriptions-item>
        </el-descriptions>
      </div>
      <div class="right" v-if="checkPermi(['ShopPhoneSetting'])">
        <!-- 自营商城相关 -->
        <el-descriptions class="margin-top" :labelStyle="{width:'150px',fontWeight:'bold',color:'#333'}" title="自营商城相关" :column="1" size="big" border>

          <!-- 在线支付开关 新 -->
          <el-descriptions-item :label="form.payOnline2.configName" v-if="checkPermi(['shopParams:payOnline'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>C端用户在自营商城中可以下单支付可选的支付方式。</span><br />
                    <span>请申请好相应的支付渠道后再开启。服务费请咨询商务。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.payOnline2.configName }}</b>
            </div>
            <div>
              <b style="display: inline-block; width: 80px;text-align: right;">微信支付：</b>
              <el-radio-group v-model="payOnline2Map.weixin" @change="submit($event,'payOnline2')">
                <el-radio label="1">启用</el-radio>
                <el-radio label="2">禁用</el-radio>
              </el-radio-group>
            </div>
            <div>
              <b style="display: inline-block; width: 80px;text-align: right;">支付宝：</b>
              <el-radio-group v-model="payOnline2Map.zhifubao" @change="submit($event,'payOnline2')">
                <el-radio label="1">启用</el-radio>
                <el-radio label="2">禁用</el-radio>
              </el-radio-group>
            </div>
            <div style="margin-top:5px;color:#999">
              <span>
                <span style="color: red;">开通前请自行申请支付宝和微信支付商户，开通支付渠道。</span><br />
              </span>
            </div>
          </el-descriptions-item>
          <!-- 服务费设置 -->
          <el-descriptions-item :label="form.serviceFeeConfig.configName" v-if="checkPermi(['shopParams:customServiceFeeConfig'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>服务费：用户在商城自行发布商品进行代售的，如果您需要收取卖家或买家的服务费，就需要设置本项。</span><br />
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.serviceFeeConfig.configName }}</b>
            </div>
            <div class="flex">
              <div>
                <el-button type="primary" style="margin-left:10px" @click="openServiceFeeConfig($event,'guaranteeConfig')">服务费设置</el-button>
              </div>
            </div>
          </el-descriptions-item>
          <!-- 自动获取开关 -->
          <el-descriptions-item :label="form.autoGetForCustom.configName" v-if="checkPermi(['shopParams:autoGetForCustom'])">
            <div slot="label">

              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>启用：C端用户在H5或APP中提发布号信息时可以使用扫码快速发布功能！</span><br />
                    <span>禁用：C端用户在H5或APP中提发布号信息时只能手动填写！</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.autoGetForCustom.configName }}</b>
            </div>
            <el-radio-group v-model="form.autoGetForCustom.configValue" @change="submit($event,'autoGetForCustom')">
              <el-radio label="1">启用</el-radio>
              <el-radio label="2">禁用</el-radio>
            </el-radio-group>
            <!-- <div style="margin-top:5px;color:#999">
    <span>启用：C端用户在H5或APP中提发布号信息时可以使用扫码快速发布功能！</span><br />
    <span>禁用：C端用户在H5或APP中提发布号信息时只能手动填写！</span>
  </div> -->
          </el-descriptions-item>
          <!-- 客服排序 -->
          <el-descriptions-item :label="form.kefusuiji.configName" v-if="checkPermi(['shopParams:kefusuiji'])">
            <div slot="label">

              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>不随机：自营商城中展示客服列表按照添加顺序排列。</span><br />
                    <span>随机：自营商城中展示客服列表顺序随机排列。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.kefusuiji.configName }}</b>
            </div>
            <el-radio-group v-model="form.kefusuiji.configValue" @change="submit($event,'kefusuiji')">
              <el-radio label="1">不随机</el-radio>
              <el-radio label="2">随机</el-radio>
            </el-radio-group>

          </el-descriptions-item>
          <!-- 下单前咨询客服提示 -->
          <el-descriptions-item :label="form.zixunTishi.configName" v-if="checkPermi(['shopParams:zixunTishi'])">
            <div slot="label">

              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>不提示：自营商城中用户下单时直接下单。</span><br />
                    <span>提示：自营商城中用户下单时提示是否已咨询客服。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.zixunTishi.configName }}</b>
            </div>
            <el-radio-group v-model="form.zixunTishi.configValue" @change="submit($event,'zixunTishi')">
              <el-radio label="1">不提示</el-radio>
              <el-radio label="2">提示</el-radio>
            </el-radio-group>

          </el-descriptions-item>

          <!-- 客服验证 客服微信填写 -->
          <el-descriptions-item :label="form.kefuyanzheng.configName" v-if="checkPermi(['shopParams:kefuyanzheng'])">
            <div slot="label">

              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>请填写所有客服的微信号/QQ号，每个号码用","隔开。用户在商城使用客服验证功能会查询是否为正确的客服。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.kefuyanzheng.configName }}</b>
            </div>
            <el-input type="textarea" rows="3" style="width: 400px;" placeholder="请填写所有客服的微信号/QQ号 每个号码用 , 隔开" @change="submit($event,'kefuyanzheng')" v-model="form.kefuyanzheng.configValue">
            </el-input>

          </el-descriptions-item>
          <!-- 客服验证页介绍 -->
          <el-descriptions-item :label="form.kfyzJieshao.configName" >
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>在自营商城中，客服验证页展示你设置的介绍语，不设置则展示默认介绍。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.kfyzJieshao.configName }}</b>
            </div>
            <el-input type="textarea" rows="3" style="width: 400px;" placeholder="请填写客服验证页介绍语" @change="submit($event,'kfyzJieshao')" v-model="form.kfyzJieshao.configValue">
            </el-input>
          </el-descriptions-item>
          <!-- 客服验证结果 错误提示语 -->
          <el-descriptions-item :label="form.kfyzErrorWord.configName" >
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>在自营商城中，客服验证结果为不通过时的提示语，不填展示系统默认提示。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.kfyzErrorWord.configName }}</b>
            </div>
            <el-input type="text" style="width: 400px;" placeholder="请填写验证不通过的提示语" @change="submit($event,'kfyzErrorWord')" v-model="form.kfyzErrorWord.configValue">
            </el-input>
          </el-descriptions-item>

          <!-- H5自营商城 风险跳转 -->
          <el-descriptions-item :label="form.fengxian.configName" v-if="checkPermi(['shopParams:fengxian'])">
            <div slot="label">

              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>启用：用户可以直接在微信浏览器中打开自营商城。</span><br />
                    <span>禁用：用户在微信内部打开自营商城时提示在浏览器打开。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.fengxian.configName }}</b>
            </div>
            <el-radio-group v-model="form.fengxian.configValue" @change="submit($event,'fengxian')">
              <el-radio label="1">启用</el-radio>
              <el-radio label="2">禁用</el-radio>
            </el-radio-group>

          </el-descriptions-item>
          <!-- H5自营商城 实名认证年龄校验 -->
          <el-descriptions-item v-if="checkPermi(['shopParams:authAge'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>设置用户实名认证时校验的年龄，低于设置的年龄时禁止认证。</span>
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.authAge.configName }}</b>
            </div>
            <el-input @change="submit($event,'authAge')" type="number" style="width:100px" v-model="form.authAge.configValue" placeholder="">
              <span style="line-height:36px" slot="suffix">岁</span>
            </el-input>

          </el-descriptions-item>

          <el-descriptions-item :label="form.saleOrderMsg.configName" v-if="checkPermi(['shopParams:customDingdanQunConfig'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>销售订单群聊创建成功后，系统自动发送到群里的消息。</span><br />
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.saleOrderMsg.configName }}</b>
            </div>
            <div class="flex">
              <div>
                <el-button type="primary" style="margin-left:10px" @click="openOrderMsg('saleOrderMsg')">消息设置</el-button>
              </div>
            </div>
          </el-descriptions-item>

          <el-descriptions-item :label="form.backOrderMsg.configName" v-if="checkPermi(['shopParams:customDingdanQunConfig'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>回收订单群聊创建成功后，系统自动发送到群里的消息。</span><br />
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.backOrderMsg.configName }}</b>
            </div>
            <div class="flex">
              <div>
                <el-button type="primary" style="margin-left:10px" @click="openOrderMsg('backOrderMsg')">消息设置</el-button>
              </div>
            </div>
          </el-descriptions-item>

          
          <el-descriptions-item :label="form.intermediaryOrderMsg.configName" v-if="checkPermi(['shopParams:customDingdanQunConfig'])">
            <div slot="label">
              <el-tooltip placement="right-start">
                <template slot="content">
                  <div style="color:#f3f3f3;font-size: 15px;">
                    <span>中介订单群聊创建成功后，系统自动发送到群里的消息。</span><br />
                  </div>
                </template>
                <span style="margin-right:5px;" class="el-icon-question"></span>
              </el-tooltip>
              <b>{{ form.intermediaryOrderMsg.configName }}</b>
            </div>
            <div class="flex">
              <div>
                <el-button type="primary" style="margin-left:10px" @click="openOrderMsg('intermediaryOrderMsg')">消息设置</el-button>
              </div>
            </div>
          </el-descriptions-item>


          <!-- 强制定位设置 -->
          <el-descriptions-item v-if="checkPermi(['shopParams:gpsForce'])">
            <div slot="label">
              <el-popover placement="top-start" title="" width="300" trigger="hover" content="如果设置为强制，在对应页面获取定位失败时不让用户进行下一步操作，请谨慎设置。">
                <span slot="reference">
                  <span  style="margin-right:5px;" class="el-icon-question"></span>
                </span>
              </el-popover>
              <b >{{ form.gpsForce.configName }}</b>
            </div>
            <div style="padding-bottom: 10px;">
              <b>回收链接：</b>
              <el-radio-group v-model="gpsForceMap.backpageLink" @change="submit($event,'gpsForce')">
                <el-radio label="1">强制</el-radio>
                <el-radio label="2">不强制</el-radio>
              </el-radio-group>
            </div>
            <div style="border-top: 1px solid #f1f1f1;padding-top: 10px;">
              <b>包赔链接：</b>
              <el-radio-group v-model="gpsForceMap.baopeiPage" @change="submit($event,'gpsForce')">
                <el-radio label="1">强制</el-radio>
                <el-radio label="2">不强制</el-radio>
              </el-radio-group>
            </div>

          </el-descriptions-item>
          <!-- 竞价回收 -->
          <el-descriptions-item v-if="checkPermi(['shopParams:bidding'])">
             <div slot="label">
              <el-popover placement="top-start" title="" width="300" trigger="hover" content="开启后，自营商城展示“竞价回收”入口，用户提交账号信息，由互联商家进行报价交易，交易成功后您将获得线索费。">
                <span slot="reference">
                  <span  style="margin-right:5px;" class="el-icon-question"></span>
                </span>
              </el-popover>
              <b >{{ form.bidding.configName }}</b>
            </div>
             <el-radio-group v-model="form.bidding.configValue" @change="submit($event,'bidding')">
              <el-radio label="1">启用</el-radio>
              <el-radio label="2">禁用</el-radio>
            </el-radio-group>
          </el-descriptions-item>
        </el-descriptions>
      </div>
    </div>

    <el-dialog title="包赔设置" :visible.sync="baopeiDialog" width="900px">
      <div>
        <div class="baopei_item" v-for="(item,i) in baopeiConfigMapList" :key="i">
          <label>
            <span>包赔名称：</span>
            <el-input style="width:200px" type="text" maxlength="8" v-model="item.name" placeholder="包赔名称,最多8字"></el-input>
          </label><br />
          <label>
            <span>包赔说明：</span>
            <el-input style="width:400px" type="textarea" :rows="4" maxlength="100" v-model="item.des" placeholder="包赔说明,最多100字"></el-input>
          </label><br />
          <label>
            <span>包赔费：</span>
            <el-input style="width:200px" type="number" max="100" min="1" v-model="item.ratio" placeholder="包赔费百分比">
              <span style="line-height:36px" slot="suffix">%</span>
            </el-input>
          </label><br />
          <label>
            <span>最低包赔费：</span>
            <el-input type="number" max="999999" min="1" style="width:200px" v-model="item.minAmount" placeholder="包赔费最低收多少">
              <span style="line-height:36px" slot="suffix">元</span>
            </el-input>
          </label>
          <i class="el-icon-delete" @click="removeBaopei(i)"></i>
        </div>
        <div class="center">
          <el-button type="primary" @click="addOneBaopei">添加</el-button>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="baopeiDialog = false">取 消</el-button>
        <el-button type="primary" @click="saveBaopei">保存</el-button>
      </span>
    </el-dialog>

    <el-dialog title="官方代售服务费设置" :visible.sync="serviceFeeConfigDialog" width="500px">
      <div>
        <el-form label-width="80px" :model="serviceFeeConfigMap">
          <div style="margin-bottom: 10px;">
            <formSubTitVue title="卖家服务费"></formSubTitVue>
          </div>
          <el-form-item label="百分比">
            <el-input style="width: 200px;" v-model="serviceFeeConfigMap.sellerRate" placeholder="按照商品金额的百分比计算">
              <template slot="suffix">
                <span>%</span>
              </template>
            </el-input>

          </el-form-item>
          <el-form-item label="最低金额">
            <el-input style="width: 200px;" v-model="serviceFeeConfigMap.sellerMin" placeholder="最少要收取多少服务费">
              <template slot="suffix">
                <span>元</span>
              </template>
            </el-input>

          </el-form-item>
          <!-- <div style="margin-bottom: 10px;">
            <formSubTitVue title="买家服务费"></formSubTitVue>
          </div>
          <el-form-item label="百分比">
            <el-input style="width: 200px;" v-model="serviceFeeConfigMap.buyerRate" placeholder="按照商品金额的百分比计算">
              <template slot="suffix">
                <span>%</span>
              </template>
            </el-input>

          </el-form-item>
          <el-form-item label="最低金额">
            <el-input style="width: 200px;" v-model="serviceFeeConfigMap.buyerMin" placeholder="最少要收取多少服务费">
              <template slot="suffix">
                <span>元</span>
              </template>
            </el-input>
          </el-form-item> -->
          <div style="margin-bottom: 10px;">
            <formSubTitVue title="提示语"></formSubTitVue>
          </div>
          <el-form-item label="快速回收">
            <el-input style="width: 200px;" v-model="serviceFeeConfigMap.kuaisuTip" placeholder="用户选择快速回收时展示的提示语">
              <!-- <template slot="suffix">
                <span>%</span>
              </template> -->
            </el-input>

          </el-form-item>
          <el-form-item label="官方代售">
            <el-input style="width: 200px;" v-model="serviceFeeConfigMap.daishouTip" placeholder="用户选择官方代售时展示的提示语">
              <!-- <template slot="suffix">
                <span>元</span>
              </template> -->
            </el-input>
          </el-form-item>

        </el-form>
        <div class="center">
          <el-button @click="serviceFeeConfigDialog = false">取 消</el-button>
          <el-button type="primary" @click="saveserviceFee">保存</el-button>
        </div>
      </div>
    </el-dialog>
<!-- 包赔端设置 -->
    <el-dialog title="包赔端设置" :visible.sync="guaranteeServiceAmountDialog" width="500px">
      <div>
        <el-form class="new_form_box" :inline="true" label-width="80px" :model="guaranteeServiceAmountMap">
          <div style="margin-bottom: 10px;">
            <formSubTitVue title="包赔费"></formSubTitVue>
          </div>
          <el-form-item label="百分比">
            <el-input  v-model="guaranteeServiceAmountMap.baifenbi" placeholder="按照商品金额的百分比计算">
              <template slot="suffix">
                <span>%</span>
              </template>
            </el-input>

          </el-form-item>
          <el-form-item label="最低金额">
            <el-input  v-model="guaranteeServiceAmountMap.minNum" placeholder="最少要收取多少包赔费">
              <template slot="suffix">
                <span>元</span>
              </template>
            </el-input>

          </el-form-item>
          <div style="margin-bottom: 10px;">
            <formSubTitVue title="手续费"></formSubTitVue>
          </div>
          <el-form-item label="手续费">
            <el-input  v-model="guaranteeServiceAmountMap.shouxufie" placeholder="包赔手续费">
              <template slot="suffix">
                <span>元</span>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item label="包赔说明" class="row">
            <el-input type="textarea" :rows="3"  v-model="guaranteeServiceAmountMap.shuoming" placeholder="请输入您的包赔规则等说明...">
            
            </el-input>
          </el-form-item>
        </el-form>
        <div class="center">
          <el-button @click="guaranteeServiceAmountDialog = false">取 消</el-button>
          <el-button type="primary" @click="saveGuaranteeServiceAmount">保存</el-button>
        </div>
      </div>
    </el-dialog>

    <el-dialog title="订单群自动发送消息" :visible.sync="groupMsgShow" width="900px">
      <div>
        <div style="color: #999;font-size: 16px;margin-bottom: 20px;">
          群聊类型：
          <b style="color: #333;" v-if="currentOrder=='backOrderMsg'">回收订单</b>
          <b style="color: #333;" v-if="currentOrder=='saleOrderMsg'">销售订单</b>
          <b style="color: #333;" v-if="currentOrder=='intermediaryOrderMsg'">中介订单</b>
        </div>
        <div style="padding: 20px;" class="baopei_item" v-for="(item,i) in qunliaoConfigMapList" :key="i">
          <div class="flex">
            <b>消息文本：</b>
            <div>
              <el-input style="width:600px" type="textarea" :rows="4" maxlength="500" v-model="item.txt" placeholder="请输入消息文本..."></el-input>
            </div>
          </div>
          <div class="flex" style="margin-top: 15px;">
            <b>消息图片：</b>
            <div>
              <uploadImageOne :showSaoma="false" v-model="item.img"></uploadImageOne>
            </div>
          </div>
          <i class="el-icon-delete" @click="removeQunxiaoxi(i)"></i>
        </div>
        <div class="center">
          <el-button type="primary" @click="addQunxiaoxi">添加</el-button>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="groupMsgShow = false">取 消</el-button>
        <el-button type="primary" @click="saveQunliao">保存</el-button>
      </span>
    </el-dialog>
    <smsSetting ref="smsSetting" @save="saveSmsSetting"></smsSetting>
    <zidongGuazhang ref="zidongGuazhang" @save="saveZidongguazhang"></zidongGuazhang>
    <autoCallSetting ref="autoCallSetting" @save="saveAutoCallSetting"></autoCallSetting>
    <!-- 租号服务费设置 -->
    <el-dialog title="租号服务费设置" :visible.sync="accountRentalDialog" width="500px">
      <div>
        <el-form class="new_form_box" :inline="true" label-width="80px" :model="guaranteeServiceAmountMap">
          <div style="margin-bottom: 10px;">
            <formSubTitVue title="租号服务费"></formSubTitVue>
  </div>
          <el-form-item label="百分比">
            <el-input  v-model="accountRentalMap.rentalServiceFee" placeholder="按照商品金额的百分比计算">
              <template slot="suffix">
                <span>%</span>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item label="最低金额">
            <el-input  v-model="accountRentalMap.rentalMinNum" placeholder="最少要收取多少租号服务费">
              <template slot="suffix">
                <span>元</span>
              </template>
            </el-input>

          </el-form-item>
        </el-form>
        <div class="center">
          <el-button @click="accountRentalDialog = false">取 消</el-button>
          <el-button type="primary" @click="saveAccountRental">保存</el-button>
        </div>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { mapGetters } from "vuex";
import {
  getShopParams,
  addShopParams,
  editShopParams,
  delShopParams,
} from "@/api/system/shopManage";
import smsSetting from "./components/smsSetting.vue";
import autoCallSetting from "./components/autoCallSetting.vue";
import zidongGuazhang from "./components/zidongGuazhang.vue";
export default {
  name: "ShopParams",
  components: {smsSetting,zidongGuazhang,autoCallSetting},
  data() {
    return {
      accountRentalDialog:false,
      guaranteeServiceAmountDialog:false,
      serviceFeeConfigDialog: false,
      baopeiDialog: false,
      groupMsgShow: false,
      currentOrder: "saleOrderMsg",
      form: {
        goodsAudit: {
          configKey: "goodsAudit",
          configValue: "2",
          configName: "商品审核开关",
        },
        gameList: {
          configKey: "gameList",
          configValue: "2",
          configName: "自定义游戏列表",
        },
        guaranteeConfig: {
          configKey: "guaranteeConfig",
          configValue: "",
          configName: "包赔费设置",
        },
        unsoldDays: {
          configKey: "unsoldDays",
          configValue: "30",
          configName: "滞销商品天数",
        },
        autoGetForCustom: {
          configKey: "autoGetForCustom",
          configValue: "1",
          configName: "C端自动获取",
        },
        payOnline: {
          configKey: "payOnline",
          configValue: "1",
          configName: "在线支付",
        },
        payOnline2: {
          configKey: "payOnline2",
          configValue: "",
          configName: "支付方式",
        },
        daishou: {
          configKey: "daishou",
          configValue: "1",
          configName: "代售授权",
        },
        kefusuiji: {
          configKey: "kefusuiji",
          configValue: "1",
          configName: "客服顺序",
        },

        kefuyanzheng: {
          configKey: "kefuyanzheng",
          configValue: "",
          configName: "客服验证",
        },

        fengxian: {
          configKey: "fengxian",
          configValue: "2",
          configName: "微信访问",
        },
        authAge: {
          configKey: "authAge",
          configValue: "0",
          configName: "实名年龄校验",
        },

        zhifutixing: {
          configKey: "zhifutixing",
          configValue: "",
          configName: "订单支付提醒",
        },

        dingding: {
          configKey: "dingding",
          configValue: "",
          configName: "钉钉群机器人",
        },
        qiyeweixin: {
          configKey: "qiyeweixin",
          configValue: "",
          configName: "企业微信群机器人",
        },

        duanxinChaxun: {
          configKey: "duanxinChaxun",
          configValue: "1",
          configName: "卡位短信设置",
        },

        serviceFeeConfig: {
          configKey: "serviceFeeConfig",
          configValue: "",
          configName: "官方代售费设置",
        },

        zixunTishi: {
          configKey: "zixunTishi",
          configValue: "1",
          configName: "咨询客服提醒",
        },
        saleOrderMsg: {
          configKey: "saleOrderMsg",
          configValue: "",
          configName: "销售群聊消息",
        },
        backOrderMsg: {
          configKey: "backOrderMsg",
          configValue: "",
          configName: "回收群聊消息",
        },
          intermediaryOrderMsg: {
          configKey: "intermediaryOrderMsg",
          configValue: "",
          configName: "中介群聊消息",
        },
        gpsForce: {
          configKey: "gpsForce",
          configValue: "",
          configName: "强制定位",
        },
        bidding: {
          configKey: "bidding",
          configValue: "2",
          configName: "竞价回收",
        },
        guaranteeServiceAmount: {
          configKey: "guaranteeServiceAmount",
          configValue: "",
          configName: "包赔端设置",
        },

        kfyzJieshao: {
          configKey: "kfyzJieshao",
          configValue: "",
          configName: "客服验证介绍",
        },
        kfyzErrorWord: {
          configKey: "kfyzErrorWord",
          configValue: "",
          configName: "客服验证不通过",
        },
        zidongguazhang: {
          configKey: "zidongguazhang",
          configValue: "",
          configName: "自动挂账设置",
        },
        quotation: {
          configKey: "quotation",
           configValue: "1",
          configName: "报价提醒短信",
        },
        autoZibianhao: {
          configKey: "autoZibianhao",
          configValue: "2",
          configName: "自动生成自编号",
        },

        duanxinguolvci: {
          configKey: "duanxinguolvci",
          configValue: "",
          configName: "短信拒收关键词",
        },
        accountRental: {
          configKey: "accountRental",
          configValue: "",
          configName: "租号服务费",
        },
        autoCallDays: {
          configKey: "autoCallDays",
          configValue: "",
          configName: "自动通话设置",
        },
      },
      accountRentalMap:{
        rentalServiceFee:'',
        rentalMinNum:'',
      },
      guaranteeServiceAmountMap:{
        minNum: "",
        baifenbi: "",
        shouxufie:'',
        shuoming:''
      },
      baopeiConfigMap: {
        minNum: "",
        baifenbi: "",
      },
      baopeiConfigMapList: [
        {
          name: "",
          des: "",
          ratio: "",
          minAmount: "",
        },
      ],
      qunliaoConfigMapList: [
        {
          img: "",
          txt: "",
        },
      ],
      zhifutixingConfigMap: {
        state: "1",
        phone: "",
      },
      dingdingMap: {
        webhook: "",
        secret: "",
      },
      payOnline2Map: {
        weixin: "2",
        zhifubao: "2",
      },
      serviceFeeConfigMap: {
        buyerRate: "",
        buyerMin: "",
        sellerRate: "",
        sellerMin: "",
        kuaisuTip: "",
        daishouTip: "",
      },
      gpsForceMap: {
        backpageLink: "2", //回收链接
        baopeiPage:'2',//包赔链接
      },
      loading: false,
    };
  },
  computed: {
    ...mapGetters(["userInfo", "shopInfo"]),
  },

  created() {
    this.getShopParams();
  },
  methods: {
    // 获取当前店铺参数
    getShopParams() {
      getShopParams().then((res) => {
        this.baopeiConfigMap.baifenbi = "";
        this.baopeiConfigMap.minNum = "";
        this.dingdingMap.webhook = "";
        this.dingdingMap.secret = "";
        this.guaranteeServiceAmountMap = {
          minNum: "",
          baifenbi: "",
          shouxufie:'',
          shuoming:''
        }

        this.gpsForceMap.backpageLink = "2";
        this.gpsForceMap.baopeiPage = "2";

        if (res.rows && res.rows.length) {
          let obj = this.arrayToObject(res.rows, "configKey");
          this.form = Object.assign(this.form, obj);
          if (
            this.form.guaranteeConfig &&
            this.form.guaranteeConfig.configValue.includes("==")
          ) {
            let arr = this.form.guaranteeConfig.configValue.split("==");
            this.baopeiConfigMap.baifenbi = arr[1];
            this.baopeiConfigMap.minNum = arr[0];
          }
          if (
            this.form.dingding &&
            this.form.dingding.configValue.includes("==")
          ) {
            let arr = this.form.dingding.configValue.split("==");
            this.dingdingMap.webhook = arr[0];
            this.dingdingMap.secret = arr[1];
          }
          if (this.form.zhifutixing && this.form.zhifutixing.configValue) {
            this.zhifutixingConfigMap = JSON.parse(
              this.form.zhifutixing.configValue
            );
          }
          if (this.form.payOnline2 && this.form.payOnline2.configValue) {
            this.payOnline2Map = JSON.parse(this.form.payOnline2.configValue);
          }
          if (
            this.form.gpsForce &&
            this.form.gpsForce.configValue
          ) {
            const obj = JSON.parse(this.form.gpsForce.configValue)
            this.gpsForceMap = {
              ...this.gpsForceMap,
              ...obj
            }
          }
         
          //console.log("%c Line:48 🌽 this.form", "color:#33a5ff", this.form);
        }
      });
    },
    // 参数改变  提交修改
    submit(e, key) {
      if (key == "zhifutixing") {
        this.form[key].configValue = JSON.stringify(this.zhifutixingConfigMap);
      }
      if (key == "dingding") {
        if (!this.dingdingMap.webhook || !this.dingdingMap.secret) {
          return this.$alert("请输入webhook地址和加签字符串");
        }
        this.form[key].configValue =
          this.dingdingMap.webhook + "==" + this.dingdingMap.secret;
      }
      if (key == "payOnline2") {
        this.form[key].configValue = JSON.stringify(this.payOnline2Map);
      }
      if (key == "guaranteeConfig") {
        // 包赔参数特殊处理
        // if (!this.baopeiConfigMap.minNum || !this.baopeiConfigMap.baifenbi) {
        //   return this.$alert("请输入包赔费或最低包赔费");
        // }
        this.form[key].configValue = JSON.stringify(this.baopeiConfigMapList);
        // this.baopeiConfigMap.minNum + "==" + this.baopeiConfigMap.baifenbi;
      }
      if (key == "serviceFeeConfig") {
        // 包赔参数特殊处理
        // if (!this.baopeiConfigMap.minNum || !this.baopeiConfigMap.baifenbi) {
        //   return this.$alert("请输入包赔费或最低包赔费");
        // }
        this.form[key].configValue = JSON.stringify(this.serviceFeeConfigMap);
        // this.baopeiConfigMap.minNum + "==" + this.baopeiConfigMap.baifenbi;
      }
      if (key == "saleOrderMsg" || key == "backOrderMsg" || key == "intermediaryOrderMsg") {
        // 消息设置处理
        this.form[key].configValue = JSON.stringify(this.qunliaoConfigMapList);
      }
      if (key == "gpsForce") {
        // 消息设置处理
        this.form[key].configValue = JSON.stringify(this.gpsForceMap);
      }
      if (key == "guaranteeServiceAmount") {
        // 包赔端设置
        this.form[key].configValue = JSON.stringify(this.guaranteeServiceAmountMap);
      }
      //租号服务费设置
      if(key == 'accountRental') {
        this.form[key].configValue = JSON.stringify(this.accountRentalMap);
      }
      if (!this.loading) {
        this.loading = true;
        if (this.form[key].id) {
          // 编辑
          editShopParams(this.form[key]).then((res) => {
            this.loading = false;
            this.$message.success(res.msg);
            this.getShopParams();
          });
        } else {
          // 新增
          addShopParams(this.form[key]).then((res) => {
            this.loading = false;
            this.$message.success(res.msg);
            this.getShopParams();
          });
        }
      }
    },
    // 打开包赔设置
    openBaopei() {
      if (
        this.form.guaranteeConfig &&
        this.form.guaranteeConfig.configValue &&
        !this.form.guaranteeConfig.configValue.includes("==")
      ) {
        this.baopeiConfigMapList = JSON.parse(
          this.form.guaranteeConfig.configValue
        );
      } else {
        this.baopeiConfigMapList = [
          {
            name: "",
            des: "",
            ratio: "",
            minAmount: "",
          },
        ];
      }

      this.baopeiDialog = true;
    },
   
    // 添加一条包赔
    addOneBaopei() {
      this.baopeiConfigMapList.push({
        name: "",
        des: "",
        ratio: "",
        minAmount: "",
      });
    },
    // 删除一条包赔
    removeBaopei(i) {
      if (this.baopeiConfigMapList.length >= 1) {
        this.baopeiConfigMapList.splice(i, 1);
      }
    },
    // 保存包赔设置
    saveBaopei() {
      let flag = true;
      if (this.baopeiConfigMapList && this.baopeiConfigMapList.length) {
        this.baopeiConfigMapList.forEach((r) => {
          if (!r.name || !r.des || !r.ratio || !r.minAmount) {
            flag = false;
          }
        });
      } else {
        this.form.guaranteeConfig.configValue = "";
      }
      if (flag) {
        this.submit("", "guaranteeConfig");
        this.baopeiDialog = false;
      } else {
        this.$message.error("请填写完整！");
      }
    },
    // 打开自动拨号设置
    openAutoCallSetting(){
      if (
        this.form.autoCallDays &&
        this.form.autoCallDays.configValue
      ) {
        this.$refs.autoCallSetting.open(this.form.autoCallDays.configValue)
      }else{
        this.$refs.autoCallSetting.open()
      }
    },
    // 保存自动拨号设置
    saveAutoCallSetting(data){
      this.form.autoCallDays.configValue = JSON.stringify(data)
      this.submit("", "autoCallDays");
    },
    // 打开短信设置弹窗
    openSmsSetting(){
      if (
        this.form.duanxinChaxun &&
        this.form.duanxinChaxun.configValue
      ) {
        this.$refs.smsSetting.open(this.form.duanxinChaxun.configValue)
      }else{
        this.$refs.smsSetting.open()
      }
      
    },
    // 保存短信设置
    saveSmsSetting(data){
      this.form.duanxinChaxun.configValue = JSON.stringify(data)
      this.submit("", "duanxinChaxun");
    },
    // 打开自动挂账设置
    openZidongguazhang(){
      if (
        this.form.zidongguazhang &&
        this.form.zidongguazhang.configValue
      ) {
        this.$refs.zidongGuazhang.open(this.form.zidongguazhang.configValue)
      }else{
        this.$refs.zidongGuazhang.open()
      }
    },
     // 保存自动挂账设置
     saveZidongguazhang(data){
      this.form.zidongguazhang.configValue = data.length>0? data.join(','):''
      this.submit("", "zidongguazhang");
    },

    // 打开订单群消息设置
    openOrderMsg(type) {
      this.currentOrder = type;
      if (type == "saleOrderMsg") {
        // 销售订单群消息
        if (this.form.saleOrderMsg && this.form.saleOrderMsg.configValue) {
          this.qunliaoConfigMapList = JSON.parse(
            this.form.saleOrderMsg.configValue
          );
        } else {
          this.qunliaoConfigMapList = [
            {
              txt: "",
              img: "",
            },
          ];
        }
      } else if (type == "backOrderMsg") {
        if (this.form.backOrderMsg && this.form.backOrderMsg.configValue) {
          this.qunliaoConfigMapList = JSON.parse(
            this.form.backOrderMsg.configValue
          );
        } else {
          this.qunliaoConfigMapList = [
            {
              txt: "",
              img: "",
            },
          ];
        }
      } else if (type == "intermediaryOrderMsg") {
        if (this.form.intermediaryOrderMsg && this.form.intermediaryOrderMsg.configValue) {
          this.qunliaoConfigMapList = JSON.parse(
            this.form.intermediaryOrderMsg.configValue
          );
        } else {
          this.qunliaoConfigMapList = [
            {
              txt: "",
              img: "",
            },
          ];
        }
      }

      this.groupMsgShow = true;
    },

    // 添加一条群消息
    addQunxiaoxi() {
      this.qunliaoConfigMapList.push({
        img: "",
        txt: "",
      });
    },
    // 删除一条群消息
    removeQunxiaoxi(i) {
      if (this.qunliaoConfigMapList.length >= 1) {
        this.qunliaoConfigMapList.splice(i, 1);
      }
    },

    // 保存 订单群消息设置
    saveQunliao() {
      let flag = true;
      if (this.qunliaoConfigMapList && this.qunliaoConfigMapList.length) {
        this.qunliaoConfigMapList.forEach((r) => {
          if (!r.txt && !r.img) {
            flag = false;
          }
        });
      } else {
        this.form[this.currentOrder].configValue = "";
      }
      if (flag) {
        this.submit("", this.currentOrder);
        this.groupMsgShow = false;
      } else {
        this.$message.error("请填写完整！");
      }
    },

    // 打开服务费设置弹窗
    openServiceFeeConfig() {
      if (
        this.form.serviceFeeConfig &&
        this.form.serviceFeeConfig.configValue
      ) {
        this.serviceFeeConfigMap = JSON.parse(
          this.form.serviceFeeConfig.configValue
        );
      } else {
        this.serviceFeeConfigMap = {
          buyerRate: "",
          buyerMin: "",
          sellerRate: "",
          sellerMin: "",
          kuaisuTip: "",
          daishouTip: "",
        };
      }
      this.serviceFeeConfigDialog = true;
    },
    // 保存服务费设置
    saveserviceFee() {
      this.submit("", "serviceFeeConfig");
      this.serviceFeeConfigDialog = false;
    },

     // 打开包赔端设置弹窗
     openGuaranteeServiceAmountDialog() {
      if (
        this.form.guaranteeServiceAmount &&
        this.form.guaranteeServiceAmount.configValue
      ) {
        const obj = JSON.parse(
                    this.form.guaranteeServiceAmount.configValue
                  )
        this.guaranteeServiceAmountMap ={
          ...this.guaranteeServiceAmountMap,
          ...obj
        }

      } else {
        this.guaranteeServiceAmountMap = {
          minNum: "",
          baifenbi: "",
          shouxufie:'',
          shuoming:''
        };
      }
      this.guaranteeServiceAmountDialog = true;
    },
    // 保存服务费设置
    saveGuaranteeServiceAmount() {
      this.submit("", "guaranteeServiceAmount");
      this.guaranteeServiceAmountDialog = false;
    },

       saveAccountRental() {
      this.submit("", "accountRental");
      this.accountRentalDialog = false;
    },
    // 删除某一配置项
    delShopParamsFn(e, id) {
      if (!id) {
        return;
      }
      delShopParams(id).then((res) => {
        this.$message.success(res.msg);
        this.getShopParams();
      });
    },
    // 将数组转为对象
    arrayToObject(arr, key = "configKey") {
      var obj = {};
      for (var i = 0; i < arr.length; i++) {
        obj[arr[i][key]] = arr[i];
      }
      return obj;
    },

    // 图片上传成功
    handleAvatarSuccess(res, file) {
      if (res.code == 200) {
        let url = res.data.filePath;
        this.form.avatar = url;
        this.editUserInfo();
      }
    },
    // 图片上传成功 营业执照
    handleAvatarSuccess2(res, file) {
      if (res.code == 200) {
        this.form.businessLicenseImg = res.data.filePath;
      }
    },

     openAcccount() {
      if (
        this.form.accountRental &&
        this.form.accountRental.configValue 
      ) {
         const obj = JSON.parse(
                    this.form.accountRental.configValue
                  )

       this.accountRentalMap ={
          ...this.accountRentalMap,
          ...obj
        }
      } else {
        this.accountRentalMap = {
           rentalServiceFee:"",
            rentalMinNum: "",
         
        };
      }

      this.accountRentalDialog = true;
    },
  },
};
</script>

<style scoped lang="scss">
.shop-config-page {
  // padding: 20px;
  // min-height: 500px;
  // background: #fff;
  // border-radius: 10px;
  // margin-top: 15px;
  .flex-box {
    column-gap: 15px;
    > div {
      width: 100%;
      box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1);
      padding: 10px;
      height: calc(100vh - 130px);
      overflow-y: auto;
      background: #fff;
      border-radius: 10px;
      padding: 15px;
      .left {
        // margin-right: 10px;
      }
    }
  }
}
.margin-top {
  margin-top: 15px;
}
.baopei_item {
  border-radius: 10px;
  background: #f9f9f9;
  padding: 15px 0;
  margin-bottom: 15px;
  position: relative;
  .el-icon-delete {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 20px;
    cursor: pointer;
  }

  label {
    display: inline-block;
    margin-bottom: 10px;
    > span {
      display: inline-block;
      width: 100px;
      text-align: right;
      vertical-align: top;
      padding-top: 7px;
    }
  }
}
</style>
